package com.atguigu.day17.test05;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Scanner;

/**
 * @author fenge
 */
public class Test05 {
    public static void main(String[] args) {
        char[] ascii = new char[26];
        for (int index = 0; index < 26; index++)
            ascii[index] = (char) ('a' + index);
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            arrayList.add("" + ascii[(int) (Math.random() * 26)]);
        }
        Iterator i = arrayList.iterator();
        for (String character : arrayList) {
            System.out.print(i.next().toString() + ",");
        }
        Scanner s = new Scanner(System.in);
        while (true) {
            String str = s.next();
            System.out.println(str + ":" + listTest(arrayList, str));
        }
    }

    public static int listTest(Collection<String> list, String s) {
        int count = 0;
        Iterator j = list.iterator();
        for (String character : list) {
            if (character.equals(s)) {
                count++;
            }
        }
        return count;
    }
}
